<?php
//prints list of pages
function pages($category, $chars, $template, $by='date', $order='DESC') {
	global $conf;

	$db = new dbquery;

	if($category) {
		if(ereg(',', $category))
		$sql="cat IN ($category) &&";
		else
		$sql="cat=$category &&";
	}

	$db->query("SELECT * FROM $conf[prefix]pages WHERE $sql visible=1 ORDER by $by $order") or $db->err(__FILE__, __LINE__);

	$list = null;

	while($p = $db->fetch_object()) {
		$t='title_'.$_SESSION['lang_short'];
		$title = read_text_rest($p->$t);
		$t='text_'.$_SESSION['lang_short'];
		$text = add_dots_(read_text($p->$t), 200);

		$title=add_dots_($title, $chars);
		$list .= string_template($template, array('url' => 'index.php?module=pages&amp;id='.$p->id, 'id' => $p->id, 'name' => $title, 'date' => date($conf['date_format'], strtotime($p->date)), 'author' => get_user_link_by_id($p->author)));
	}

	echo($list);
}

function menu_page($id_, $template) {
	global $conf;

	$db = new dbquery;

	$db->query("SELECT * FROM $conf[prefix]pages WHERE id=$id_") or $db->err(__FILE__, __LINE__);

	$p=$db->fetch_object();

	$t='title_'.$_SESSION['lang_short'];
	$title = $p->$t;
	$t='text_'.$_SESSION['lang_short'];
	$text = read_text($p->$t);

	$list = string_template($template, array('url' => 'index.php?module=pages&amp;id='.$p->id, 'id' => $p->id, 'name' => read_text_rest($title), 'date' => date($conf['date_format'], strtotime($p->date)), 'author' => get_user_link_by_id($p->author), 'text' => $text));

	echo($list);
}

?>
